{extend name="template/base" /}
{block name="content"}
<div class="page-container">
    {include file="form" /}
    <div class="cl pd-5 bg-1 bk-gray">
        <span class="l">
                        <a class="btn btn-primary radius mr-5" id="sou" href="{:url('/admin/dispatch_traveler_group/export_to_excel/account/2',$searchCondition)}" >excel导出</a>
            <!--{tp:menu menu="add" /}-->
            <!--<a class="btn btn-primary radius mr-5" href="{:url('/admin/dispatch_traveler_group/export_to_excel',$searchCondition)}"  >excel导出</a>-->
            <!--<a class="btn btn-primary radius mr-5" id="sou" href="{:url('/admin/dispatch_traveler_group/export_to_excel',$searchCondition)}" >excel导出</a>-->
            <!--<a class="btn btn-primary radius mr-5" id="xuan" style="display: none;"  href="javascript:;" onclick="xuan()">excel导出</a>-->
        </span>
        <span class="r pt-5 pr-5">
            共有数据 ：<strong>{$count ?? '0'}</strong> 条
        </span>
    </div>
    <?php use think\Db;?>
    <table class="table table-border table-bordered table-hover table-bg mt-20">
        <thead>
        <tr class="text-c">
            <th>派车单信息</th>
            <th>司机信息</th>
            <th>客人信息</th>
            <th>评价信息</th>
            <th>时间</th>
            <th>结算信息</th>
            <th>拒绝原因</th>
            <th>备注</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {volist id="list" name="list_data"}
        <tr class="text-c">
            <td><br>派车单号：{$list.id}<br>标题：{$list.title}<br>线路名称：{$list.route_title}</td>
            <td><br>司机姓名：{// $list.realname}
                <a title="详细资料" href="javascript:;" onclick="driverInfo({$list.driver_user_id})" style="text-decoration:none">
                    {$list.realname}
                </a>
                <br>司机等级：{$list.driver_rank_id}<br>车辆等级：{$list.vehicle_level}<br>用车形式：{$list.car_form}</td>
            <td style="max-width: 200px"><br>客人姓名：{$list.booking_people_name}<br>客人数量：{$list.booking_people_num}</td>
            <td><br>好评数：{$list.comment_praise}<br>差评数：{$list.comment_negative}<br>好评比率：{$list.feedback}%<br>是否达标：{$list.is_reach_standard}</td>
            <td>
                <br>出发时间：{$list.go_date?date('Y-m-d H:i',$list.go_date):"--"}
                <br>结束时间：{$list.end_date?date('Y-m-d H:i',$list.end_date):"--"}
                <br>申请结算时间：{$list.apply_settlement_time?date('Y-m-d H:i:s',$list.apply_settlement_time):"--"}
                <br>拒绝结算时间：{$list.reject_settlement_time?date('Y-m-d H:i:s',$list.reject_settlement_time):"--"}
            </td>
            {if $list.driver_from == 1}
            <td>
                <br>预支付标准：{$list.prepaid_expenses}
                <br>初始油表：{$list.start_gauge_value}
                <br>结束油表：{$list.end_gauge_value}
                <br>初始里程：{$list.start_odometer_value}
                <br>结束里程：{$list.end_odometer_value}
                <br>差评扣款：{$list.deduct_money}
                <br>其它扣款：{$list.other_deduct_money}
            </td>
            {else/}
            <td>
                <br>司机费用：{$list.driver_fee}
                <br>司机补偿金：{$list.driver_compensation}
                <br>公司补偿金：{$list.company_compensation}
                <br>差评扣款：{$list.deduct_money}
                <br>其它扣款：{$list.other_deduct_money}
                {php}
                    $list['insurance_expenses'] = Db::name('dispatch_insurance')->where('group_id',$list['id'])->value('insurance_money');
                {/php}
                <br>保险费用：{$list.insurance_expenses?:'0'}
            </td>
            {/if}
            <td style="max-width: 200px"><span class="width:100%;height:auto;word-wrap:break-word;word-break:break-all;">{$list.reject_settlement_reason}</span></td>
            <td style="max-width: 200px"><span class="width:100%;height:auto;word-wrap:break-word;word-break:break-all;">{$list.remark}</span></td>
            <td>
                <a title="派车单信息" href="javascript:;" onclick="layer_open('派车单信息','/admin/dispatch_traveler_group/dispatch_details/group_id/{$list.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">派车单信息</a>
                <a href="javascript:;" onclick="layer_open('好评奖励','/admin/dispatch_traveler_group/good_reward/group_id/{$list.id}')" class="label label-warning radius" title="好评奖励">好评奖励</a>
                {if $list.driver_from == 1}
                <a href="javascript:;" onclick="layer_open('预支付信息','/admin/dispatch_traveler_group/prepayment/group_id/{$vo.id}')" class="label label-warning radius" title="预支付信息">预支付信息</a>
                {/if}
                <a href="javascript:;" onclick="layer_open('再次申请','/admin/dispatch_traveler_group/apply_settlement/type/reapply/group_id/{$list.id}')" class="label label-warning radius" title="再次申请">再次申请</a>
                <a title="编辑" href="javascript:;" onclick="layer_open('编辑','/admin/dispatch_traveler_group/dispatch_edit/id/{$list.id}')" style="text-decoration:none" class="ml-5 label label-warning radius">编辑</a>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page-bootstrap">{$page ?? ''}</div>
</div>
{/block}

{block name="script"}
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>

<script>

    function reset_group(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                layer.msg(re.msg, {
                    time: 2000, //2s后自动关闭
                },function () {
                    //关闭后刷新
                    location.reload();
                });
            },
        });
    }
    function settlement(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                layer.msg(re.msg, {
                    time: 2000, //2s后自动关闭
                },function () {
                    //关闭后刷新
                    location.reload();
                });
            },
        });
    }
    function reject_settlement(url) {
        $.ajax({
            type: 'POST',
            url: url,
            data: null,
            success: function (re){
                layer.msg(re.msg, {
                    time: 2000, //2s后自动关闭
                },function () {
                    //关闭后刷新
                    location.reload();
                });
            },
        });
    }
    $(function () {
        $("[name='car_form']").find("[value='{$Request.param.car_form}']").attr("selected", true);
    })

    //全选
    $('#checkAlls').bind("click", function () {
        $("input[name='id[]']").prop("checked",this.checked);
        var sonChecked = $("input[name='id[]']").prop('checked');
        var allChecked = this.checked
        if (sonChecked && allChecked){
            $('#xuan').css('display','inline') // 显示选择excel导出数据
            $('#sou').css('display','none') // 隐藏部分或全部excel导出数据
        }else{
            $('#xuan').css('display','none')
            $('#sou').css('display','inline')
        }
        // console.log('你点击我了')
        // console.log('你是否被选中', this.checked)
        // console.log('下级的选框', $("input[name='id[]']").prop('checked'))
    });

    // 单选
    $("input[name='id[]']").bind('click', function () {
        var radioData =  $("input:checked[name='id[]']");
        // 选择数据的长度
        var len = radioData.serializeArray().length;
        if (len > 0) {
            $('#xuan').css('display','inline') // 显示选择excel导出数据
            $('#sou').css('display','none') // 隐藏部分或全部excel导出数据
        } else {
            $('#xuan').css('display','none')
            $('#sou').css('display','inline')
            $('#checkAlls').prop('checked',false); // 取消选择全选按钮
        }
        // console.log('你点击了单选')
        // console.log('点击的结果为：', this.checked)
        // console.log('你选择的数据是', radioData.serializeArray())
        // console.log('你选择的数据长度是',len)
    });

    function xuan() {
        var checkData = $("input:checked[name='id[]']");
        var dataArr = checkData.serializeArray();
        dataArr.push({name: 'search',value: 'accounts'})
        // console.log('选择的数据是', checkData.length)
        // console.log('选择的数据是', checkData.serializeArray())
        // console.log('选择的数组是', dataArr)
        $.ajax({
            type: 'post',
            url: '/admin/dispatch_traveler_group/export_to_excel',
            data: dataArr,
            success: function (res) {
                if (res.code == 5){
                    // console.log('data', res);
                    location.href = res.msg; // 下载文件
                    // 删除文件
                    unclinkFile(res.msg)
                    layer.msg('导出数据成功');
                } else {
                    layer_open('excel导出数据','/admin/pub/role/id/1')
                }
            }
        });
    }
    var  value = 1;
    setTimeout(unclinkFile,1200000,value); // 延迟20分钟1200000
    // 15分钟后删除文件-900000
    function unclinkFile(val) {
        console.log(val)
        setTimeout(function () {
            // 删除文件
            $.ajax({
                type: 'post',
                url: '/admin/order/del',
                data: {val:val},
                success: function (data) {
                    console.log('data', data)
                    if (data.code != 5) {
                        console.log('删除失败', data.msg)
                    }
                }
            })
        },120000,val); // 2分钟后执行
    }
</script>

<script>
    function driverInfo(id) {
        var url = '/admin/driver/details';
        if (!id){
            layer.msg('缺少必要的参数');
        }
        $.ajax({
            type: 'get',
            url: url,
            data:{ id: id },
            success: function (data) {
                if (data.code == 1){
                    layer.msg(data.msg)
                    return false
                }else{
                    layer_open('详细资料','/admin/driver/details/id/'+id,{w:'1300px',h:'750px'})
                }
            }
        })
    }
</script>
{/block}